import { get, post, put, del } from '../../../utils/request';

export function institutions() {
  return get('v1/insurance-products');
}
export function getMembers(customerId) {
  return get(`v1/customers/${customerId}/family`);
}
export function getMember(customerId, memberId) {
  return get(`v1/customers/${customerId}/family/${memberId}`);
}
export function updateMember(customerId, member = {}) {
  return put(
    `v1/customers/${customerId}/family/${member.customerFamilyMemberId}`,
    member
  );
}

/* 客户模块api */

export function getCustomers(params = {}) {
  return get('v1/customers', params);
}
export function getCustomer(id) {
  return get(`v1/customers/${id}`);
}
export function createCustomer(params = {}) {
  return post('v1/customers', params);
}
export function updateCustomer(params = {}) {
  return put('v1/customers', params);
}
export function removeCustomer(id) {
  return del(`v1/customers/${id}`);
}

/* 保单模块api */
export function getPolicies(id) {
  return get(`v1/customers/${id}/policies`);
}
export function getPolicy(customerId, policyId) {
  return get(`v1/customers/${customerId}/policies/${policyId}`);
}
export function removePolicy(customerId, id) {
  return del(`v1/customers/${customerId}/policies/${id}`);
}
export function createPolicy(customerId, policy) {
  return post(`v1/customers/${customerId}/policies`, policy);
}
export function updatePolicy(customerId, policy) {
  const { policyId, ...other } = policy;
  return put(`v1/customers/${customerId}/policies/${policyId}`, other);
}
